#!/usr/bin/env bash

# install-go.sh

# This program will install the Go programming language on the Ubuntu GNU/Linux
# operating system.

# Copyright (C) 2009 Scott C. MacCallum
# scottmaccal@gmail.com

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses.

install-go

#-
# Export the Go environment variables for temporary use.
#-   

export PATH=$PATH:$HOME/bin

export GOROOT=$HOME/go

export GOARCH=386

export GOOS=linux

#-
# Add the Go environment variables to .bashrc for perminate use.
#-

echo PATH=$PATH:$HOME/bin >> $HOME/.bashrc

echo GOROOT=$HOME/go >> $HOME/.bashrc

echo GOARCH=386 >> $HOME/.bashrc

echo GOOS=linux >> $HOME/.bashrc

#-
# Install the packages Go depends on.
#-

sudo apt-get install hg

sudo apt-get install ed

sudo apt-get install bison

sudo apt-get install gcc

sudo apt-get install libc6-dev

sudo apt-get install make

#-
# Make the directories Go requires.
#-

mkdir $HOME/bin

mkdir $HOME/go

#-
# Get the Go source code from the Go repository.
#-

hg clone -r release https://go.googlecode.com/hg/ $HOME/go

#-
# Change to the Go source directory
#-

cd $HOME/go/src

#-
# Change the mode of the following file.
#-

chmod +x $HOME/go/src/all.bash

#-
# Execute the following file.
#-   

./all.bash
# END OF FILE